import { Dropdown } from "antd";
import { connect } from "react-redux";
import { changeLanguageAction } from "@/redux/modules/permission/asyncAction";

const Language = (props: any) => {
	const { language } = props;

	const items = [
		{
			key: "2",
			label: <span>English</span>,
			onClick: () => changeLanguageAction("en"),
			disabled: language === "en"
		},
		{
			key: "3",
			label: <span>Tiếng Việt</span>,
			onClick: () => changeLanguageAction("vi"),
			disabled: language === "vi"
		}
	];

	return (
		<Dropdown menu={{ items }} placement="bottom" trigger={["click"]} arrow={true}>
			<i className="icon-style iconfont icon-zhongyingwen"></i>
		</Dropdown>
	);
};

const mapStateToProps = (state: any) => state.global;
export default connect(mapStateToProps, null)(Language);
